<div id="sms_sent_ildds" class="easyui-layout tab_a" fit="true">
    <div data-options="region:'center',border:false">
        <table id="sms_sent_list"></table>
        <div id="smssentboxtoolbar" style="padding:5px;height:auto">        	
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="remind_reset()">重新提醒</a>
            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="sentbox_del()">删除</a>
            <label style=" float:right;">
                	<input id="sms_sent_search_key" class="sms_sent_search_form textbox" style="width:200px" type="text">
                	<a href="#" class="easyui-linkbutton sms_sent_search_form" iconCls="icon-search" onclick="advanced_search('sms_sent','sms_sent_search_key')">搜索</a>
                <a id="sms_sent_advancedSearch" href="javascript:void(0)" class="easyui-linkbutton" plain="true" onclick="advanced_search('sms_sent','高级')">高级</a>
            </label>
        </div>
	</div>
</div>
<script>
//发件箱数据构造方法，包括列表属性设置，字段设置，双击设置
$('#sms_sent_list').datagrid({
    url:'<?php echo base_url('sms/sentbox_data');?>',
	method:'post',
	singleSelect:true,
	selectOnCheck:false,
	pagination:true,
	pageSize:30,
	pageList:[30,50,100],
	fit:true,
	fitColumns:true,
	border:false,
	queryParams:{},
	sortName:'bodyid',
	sortOrder:'desc',
	toolbar:'#smssentboxtoolbar',
    columns:[[
		{field:'bodyid',checkbox:true},
		{field:'smstype',title:'类型',width:10,align:'center',
			formatter: function(value,row,index){
				switch(value){
				case 1:
					return "<div class='icon-sound' style='height: 16px;'></div>";	
					break;
				case 2:
					return "<div class='icon-email' style='height: 16px;'></div>";	
					break;
				default:
					return "<div class='icon-sound' style='height: 16px;'></div>";	
				}
			}
		},
        {field:'to_name',title:'收信人',width:16,align:'center',
			formatter: function(value,row,index){
				return subStringCh(value,8,true);
			}
		},
        {field:'title',title:'内容',width:200},
        {field:'readtime',title:'提醒时间',width:30,align:'center',sortable:'true',
			formatter: function(value,row,index){
				//return getLocalTime(value);
				return value;
			}
		}
    ]],
	onLoadSuccess:function(){
        var pager = $(this).datagrid('getPager');
        pager.pagination({
            displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'
        });
    }
});


//重置提醒
function remind_reset(){
	var getobj = $('#sms_sent_list').datagrid("getChecked");
	var data = [];
		$.each(getobj, function(index, item){
			data.push(item);
		}); 
	if(data.length == 0){
		$.messager.alert('错误','操作前需选择至少一行','error');
	}else{            
		$.post("<?php echo base_url('sms/remind_reset');?>",{data:data},function(result){
			if(result.success){
				$('#sms_sent_list').datagrid('reload');
			}else{
				$.messager.alert('错误',result.errorMsg,'error');
			}
		},'json');
	}
}

//"删除已发短信列表"函数
function sentbox_del(){
	var getobj = $('#sms_sent_list').datagrid("getChecked");
	var getid = [];
		$.each(getobj, function(index, item){
			getid.push(item.bodyid);
		}); 
	if(getid.length == 0){
		$.messager.alert('提示','要删除已发邮件，请选取要操作的行','warning');
	}else{  
	   $.messager.confirm('提示', '确定要删除选中的邮件吗?', function(r){
			if(r){       
				$.post("<?php echo base_url('sms/sentbox_del');?>",{getid:getid},function(result){
					if(result.success){
						$('#sms_sent_list').datagrid('reload');
					}else{
						$.messager.alert('错误',result.errorMsg,'error');
					}
				},'json');
			}
		});	
	}
}



</script>